﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Excel.Model
{
    public class Dbhepler
    {
        public static SqlSugarClient DbheplerMysql()
        {
            SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
            {
                //Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;
                ConnectionString = $"Data Source=192.168.211.132;Initial Catalog=wukuang;User ID=sa;Trust Server Certificate=True;Password=zdf19980525.",
                DbType = DbType.SqlServer,
                IsAutoCloseConnection = true
            },
            db =>
            {
                db.Aop.OnLogExecuting = (sql, pars) =>
                {
                    var sqsl = UtilMethods.GetSqlString(DbType.SqlServer, sql, pars);
                    //获取原生SQL推荐 5.1.4.63  性能OK
                    //Console.WriteLine(UtilMethods.GetNativeSql(sql, pars));
                    //获取无参数化SQL 对性能有影响，特别大的SQL参数多的，调试使用
                    //Console.WriteLine(UtilMethods.GetSqlString(DbType.SqlServer,sql,pars))
                };
            });
            //Db.DbMaintenance.CreateDatabase();
            //Db.CodeFirst.InitTables(typeof(T_Opex_pve_analysis)); //pve
            return Db;
        }
    }
}
